#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct ListNode {
    int              val;
    struct ListNode* next;
};

class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * @param head ListNode类
     * @return ListNode类
     */
    ListNode* reorderList( ListNode* head ) {
        // write code here

        if ( head == nullptr || head->next == nullptr || head->next->next == nullptr ) {
            return head;
        }

        ListNode* ptr1    = head;
        ListNode* ptr2    = head->next;
        ListNode* newHead = ptr2->next;
        ListNode* nextGroup1;
        ListNode* nextGroup2;
        ListNode* temp;
        ListNode* grouptail = newHead->next;

        while ( ptr2->next != nullptr && ptr2 != nullptr ) {
            nextGroup1 = ptr2->next;
            nextGroup2 = nextGroup1->next;

            if ( nextGroup2 != nullptr ) {
                temp             = nextGroup2->next;
                nextGroup2->next = ptr1;
                ptr2->next       = temp;

                if ( grouptail != newHead->next ) {
                    grouptail->next = nextGroup1;
                }
            }
            else {
                nextGroup1->next = ptr1;
                ptr2->next       = nullptr;
                grouptail->next  = nextGroup1;
                return newHead;
            }

            grouptail = ptr2;
            ptr1      = temp;
            ptr2      = temp->next;
        }

        return newHead;
    }
};



vector< string > findDuplicate( vector< string > a, string b ) {

    vector< int > letters( 26 );
    ;
    for ( int i = 0; i < 26; i++ ) {
        letters[ i ] = -1;
    }

    vector< string > ans;

    for ( int i = 0; i < a.size(); i++ ) {

        string str = a[ i ];

        for ( int p = 0; p < str.size(); p++ ) {
            letters[ str[ p ] - 'a' ] = 1;
        }

        for ( int j = 0; j < b.size(); j++ ) {
            if ( letters[ b[ j ] - 'a' ] != -1 ) {
                ans.push_back( str + b[ j ] );
            }
        }

        for ( int i = 0; i < 26; i++ ) {
            letters[ i ] = -1;
        }
    }

    return ans;
}

int main() {
    int n = 0;
    cin >> n;
    vector< string > num( n );
    for ( int i = 0; i < n; i++ ) {
        string s;
        cin >> s;
        num.push_back( s );
    }

    vector< string > ans;
    vector< string > temp;

    string str1 = num[ 0 ];

    for ( int i = 0; i < str1.size(); i++ ) {
        string ss = "";
        ss += str1[ i ];
        temp.push_back( ss );
    }

    for ( int i = 0; i < n; i++ ) {

        ans = findDuplicate( temp, num[ i + 1 ] );
    }

    cout << ans.size() << endl;
    return 0;
}